package cn.vshare.service.impl;

import cn.vshare.dao.UserDao;
import cn.vshare.entity.Role;
import cn.vshare.entity.User;
import cn.vshare.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;

    @Override
    public List<User> getAllFriend(User user) {
        return userDao.getAllFriend(user);
    }

    @Override
    public User login(User user) {
        return userDao.login(user);
    }

    @Override
    public int register(User user) {
        return userDao.addUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userDao.updateUser(user);
    }

    @Override
    public void delUserById(String id) {
        User user = new User();
        user.setId(id);
        userDao.delUser(user);
    }

    @Override
    public void recoverDelUser(String id) {
        User user = new User();
        user.setId(id);
        userDao.RecoverDelUser(user);
    }


    @Override
    public User queryUserById(User user) {
        return userDao.queryUserById(user);
    }

    @Override
    public int countUserByRole(Role role) {
        return userDao.countUserByRole(role);
    }

    @Override
    public void addFriend(Map map) {
        userDao.addFriend(map);
    }

    @Override
    public int isExistFriend(String myId, String friendId) {
        return userDao.isExistFriend(myId,friendId);
    }

    @Override
    public void removeFriend(String myId, String friendId) {
        userDao.removeFriend(myId,friendId);
    }
}
